//: [Previous](@previous)

import Foundation

var greeting = "Hello, playground"

//: [Next](@next)

print(greeting.startIndex)
print(greeting[greeting.startIndex])
print(greeting.endIndex)
print(greeting[greeting.index(before: greeting.endIndex)])

// 插入字符
greeting.insert("!", at: greeting.endIndex)
print(greeting)

// 插入字符串
greeting.insert(contentsOf: " there", at: greeting.endIndex)
print(greeting)

// 删除最后一个字符
greeting.remove(at: greeting.index(before: greeting.endIndex))
print(greeting)

// 删除区间字符串
let range = greeting.index(greeting.endIndex, offsetBy: -10)..<greeting.endIndex
greeting .removeSubrange(range)
print(greeting)

